<template>
  <el-form ref="form" :model="form" label-width="80px">
    <el-form-item label="商品名称">
      <el-input v-model="form.ProName"></el-input>
    </el-form-item>

    <el-form-item label="商品分类">
      <el-select v-model="form.TypeID" placeholder="商品分类">
        <el-option
          v-for="item in optionss"
          :key="item.ProTypeID"
          :label="item.ProTypeName"
          :value="item.ProTypeID"
        >
        </el-option>
      </el-select>
    </el-form-item>

    <el-form-item label="文件上传">
      <!-- <el-upload
        class="upload-demo"
        action="https://jsonplaceholder.typicode.com/posts/"
        :on-preview="handlePreview"
        :on-remove="handleRemove"
        :before-remove="beforeRemove"
        multiple
        :limit="3"
        :on-exceed="handleExceed"
        :file-list="fileList"
      >
        <el-button size="small" type="primary">点击上传</el-button>
        <div slot="tip" class="el-upload__tip">
          只能上传jpg/png文件，且不超过500kb
        </div>
      </el-upload> -->
    </el-form-item>

    <el-form-item label="商品价格">
      <el-input v-model="form.Price"></el-input>
    </el-form-item>

    <el-form-item label="商品划线价">
      <el-input v-model="form.Tprice"></el-input>
    </el-form-item>

    <el-form-item label="当前库存数量">
      <el-input v-model="form.Num"></el-input>
    </el-form-item>

    <el-form-item label="商品重量(Kg) ">
      <el-input v-model="form.Weight"></el-input>
    </el-form-item>

    <el-form-item label="库存计算方式">
      <el-radio-group v-model="form.Cal">
        <el-radio label="1">下单减库存</el-radio>
        <el-radio label="0">减库存</el-radio>
      </el-radio-group>
    </el-form-item>

    <el-form-item label="商品详情">
      <el-input type="textarea" v-model="form.Info"></el-input>
    </el-form-item>

    <el-form-item label="运费模板">
      <el-select v-model="form.LogisticsID" placeholder="请选择运费模板">
        <el-option
          v-for="item in options"
          :key="item.LogisticsID"
          :label="item.SendCity"
          :value="item.LogisticsID"
        >
        </el-option>
      </el-select>
    </el-form-item>

    <el-form-item>
      <el-button type="primary" @click="onSubmit">立即创建</el-button>
      <el-button>取消</el-button>
    </el-form-item>
  </el-form>
</template>
<script>
export default {
  data() {
    return {
      form: {},
      optionss: {},
      options: {},
      Product:[],
      Setting:[],
      
    };
  },
  mounted() {
    this.op();
  },
  methods: {
    op() {
      this.axios
        .get(
          "https://localhost:44375/api/ProductType/GetProductTypes?pageIndex=1&pageSize=99"
        )
        .then((response) => {
          this.optionss = response.data.data.Result;
        });
      this.opp();
    },
    opp() {
      this.axios
        .get("https://localhost:44375/api/Logt/GetLogistics")
        .then((response) => {
          console.log(response.data);
          this.options = response.data;
        });
    },
    onSubmit() {

      this.axios
        .post("https://localhost:44375/api/Product/AddProduct", this.form)
        .then((response) => {
          if (response > 0) {
            alert("成功");
          }
          if (response == 0) {
            alert("失败");
          }
        });
    },
  },
};
</script>